home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
cstdio.arc
/
SRC.ARC
/
STRRCHR.A
< prev
next >
Wrap
Text File
|
1985-08-20
|
672b
|
32 lines
; strrchr.a - find last occurrence of character in string.
; (C) Copyright 1985 Cray Research Inc. - All Rights Reserved.
; G. R. Mansfield. 85/08/20.
; Ver 1.0-5820.
cseg
public strrchr_
public rindex_
; char *strrchr(s, c) /* return pointer to last occurrence of c */
; char *rindex(s, c) /* in s NULL if c is not in s */
; char *s;
; int c;
strrchr_:
rindex_:
mov bx,sp
mov si,[bx+2] ; s
mov ah,[bx+4] ; c
mov bx,1 ; preset NULL
stc1: lodsb ; next character in s
cmp al,ah
jnz stc2 ; if not found
mov bx,si ; pointer to c
stc2: or al,al
jnz stc1 ; loop to end of string
xchg ax,bx ; return pointer
dec ax
ret